﻿using System;
using System.Collections.Generic;
using System.Data.OleDb;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Common;

namespace Print
{
    public partial class Base : PrintPageBase
    {
        private PBLL.PMenu bllMenu = new PBLL.PMenu();
        private string t = "";

        public string mid = "";
        public string aid = "";

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (string.IsNullOrEmpty(Request.QueryString["t"]))
                {
                    Response.Redirect(config.P_WebPath);
                }
                string title = config.P_Title;
                t = Request.QueryString["t"].ToString();
                BaseRpt.DataSource = bllMenu.GetList("AShow=true");
                detials.InnerHtml = t;
                OleDbDataReader dr = bllMenu.GetDr("MUrl='" + t + ".aspx'");
                if (dr.Read())
                {
                    bTit.InnerHtml = "<strong>" + dr["MCn"].ToString() + "</strong> <span class=\"soft\">" + dr["MEn"].ToString() + "</span>";
                    string cont = dr["MInfo"].ToString();
                    if (t == "contact")
                    {
                        cont += "<div id=\"map\"></div>\n";
                        cont += "<script type=\"text/javascript\" src=\"http://api.map.baidu.com/api?v=1.2&services=true\"></script>\n";
                        cont += "<script type=\"text/javascript\">\n";
                        cont += "var map = new BMap.Map('map');\n";
                        cont += "map.addControl(new BMap.NavigationControl());\n"; 

                        cont += "var point = new BMap.Point(113.304463, 22.212849);\n";

                        cont += "map.centerAndZoom(point,18);\n</script>\n";

                    }
                    GetAd(AdRpt, dr["MTitle"].ToString());
                    title = dr["MTitle"].ToString() + "-" + config.P_Name;
                    aid = dr["Id"].ToString();
                    mid = bool.Parse(dr["MShow"].ToString()) ? aid : "1";
                    detials.InnerHtml = cont;
                    
                }
                Page.Header.Title = title;
                Page.DataBind();
            }
        }
    }
}